<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Tuxxedo Engine API Documentation</title>

		<link rel="stylesheet" href="./style.css" media="all" type="text/css" />
	</head>
	<body>

<h1>\Tuxxedo\LocalCache</h1>
<div class="box">
	<div class="inner">
		<div class="left-content">
			<fieldset>
				<legend><strong>Meta information</strong></legend>
				<table cellspacing="4" cellpadding="0">
					<tr>
						<td>Availability:</td>
						<td class="value" style="width: 100%">
							Tuxxedo Engine 1.2.0
						</td>
					</tr>
					<tr>
						<td>Type:</td>
						<td class="value" style="width: 100%">
							<a href="./classes.html">Class</a>
						</td>
					</tr>
					<tr>
	<td nowrap="nowrap">Namespace:</td>
	<td class="value" style="width: 100%" nowrap="nowrap">
		<a href="namespace-tuxxedo-167390.html">\Tuxxedo</a>
	</td>
</tr><tr>
	<td nowrap="nowrap">Declared in:</td>
	<td class="value" style="width: 100%" nowrap="nowrap">
		library/Tuxxedo/LocalCache.php
	</td>
</tr>
				</table>
			</fieldset>
		</div>
		<div class="content">
			<div class="infobox">
				Local cache registry<br />This class implements a localized cache registry for a
script request or instance. This works much like the
datastore cache except that it works with live data.<br />The design and need for this class comes from as a need
from the datamanager component orignally to prevent having
to send queries to the database and sacrifice that network
communication for script memory.<br />
			</div>
			<br />
		</div>
		<div style="clear: left;"></div>
	</div>
</div>





<h2><span>Contents</span></h2>
<div class="box edge-title">
	<div class="inner">
		<div class="infobox">
			Table of contents
		</div>

		<h3>
	Properties
	<a name="properties"></a>
</h3>
<table style="width: 100%" cellspacing="2" cellpadding="0">
	<tr class="head">
		<td class="strong" nowrap="nowrap" style="width: 20%;">Property</td>
		<td class="strong">Description</td>
	</tr>
	<tr class="row">
	<td nowrap="nowrap"><a href="property-cache-693613.html">$cache</a></td>
	<td nowrap="nowrap" style="width: 100%"><span class="tag">Protected</span>&nbsp;Holds the cached elements from the datastore</td>
</tr><tr class="row">
	<td nowrap="nowrap"><a href="property-db-042349.html">$db</a></td>
	<td nowrap="nowrap" style="width: 100%"><span class="tag">Protected</span>&nbsp;Database instance</td>
</tr>
</table><h3>
	Methods
	<a name="methods"></a>
</h3>
<table style="width: 100%" cellspacing="2" cellpadding="0">
	<tr class="head">
		<td class="strong" nowrap="nowrap" style="width: 20%;">Method</td>
		<td class="strong">Description</td>
	</tr>
	<tr class="row">
	<td nowrap="nowrap"><a href="method---construct-745915.html">__construct()</a></td>
	<td nowrap="nowrap" style="width: 100%">Constructor</td>
</tr><tr class="row">
	<td nowrap="nowrap"><a href="method-find-387070.html">find()</a></td>
	<td nowrap="nowrap" style="width: 100%">Finds an entry</td>
</tr><tr class="row">
	<td nowrap="nowrap"><a href="method-findspecific-564817.html">findSpecific()</a></td>
	<td nowrap="nowrap" style="width: 100%">Finds a specific entry</td>
</tr><tr class="row">
	<td nowrap="nowrap"><a href="method-getnum-436684.html">getNum()</a></td>
	<td nowrap="nowrap" style="width: 100%">Gets the number of entries for a specific entry</td>
</tr><tr class="row">
	<td nowrap="nowrap"><a href="method-load-560860.html">load()</a></td>
	<td nowrap="nowrap" style="width: 100%">Loads a specific table into the cache</td>
</tr><tr class="row">
	<td nowrap="nowrap"><a href="method-lookup-228732.html">lookup()</a></td>
	<td nowrap="nowrap" style="width: 100%"><span class="tag">Protected</span>&nbsp;Internal lookup method</td>
</tr><tr class="row">
	<td nowrap="nowrap"><a href="method-unload-345979.html">unload()</a></td>
	<td nowrap="nowrap" style="width: 100%">Unloads one or more cached entries</td>
</tr>
</table>
	</div>
</div>

<h2><span>Examples</span></h2>
<div class="box edge-title">
	<div class="inner">
		<fieldset>
	<legend><strong>Example #1</strong></legend>
	<table cellspacing="4" cellpadding="0" style="width: 100%;">
		<tr> 
			<td colspan="2" class="value" style="width: 100%">
				<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">use&nbsp;</span><span style="color: #0000BB">Tuxxedo</span><span style="color: #007700">\</span><span style="color: #0000BB">LocalCache</span><span style="color: #007700">;<br />use&nbsp;</span><span style="color: #0000BB">Tuxxedo</span><span style="color: #007700">\</span><span style="color: #0000BB">Registry</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//Registry<br /></span><span style="color: #0000BB">$registry&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">Registry</span><span style="color: #007700">::</span><span style="color: #0000BB">init</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//Load&nbsp;LocalCache<br /></span><span style="color: #0000BB">$registry</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">'lcache'</span><span style="color: #007700">,&nbsp;new&nbsp;</span><span style="color: #0000BB">LocalCache</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//We&nbsp;need&nbsp;to&nbsp;get&nbsp;all&nbsp;the&nbsp;books,&nbsp;but&nbsp;our&nbsp;library&nbsp;<br />//is&nbsp;big,&nbsp;and&nbsp;have&nbsp;over&nbsp;1000&nbsp;entries,&nbsp;so&nbsp;to&nbsp;prevent&nbsp;<br />//filling&nbsp;up&nbsp;the&nbsp;entire&nbsp;memory&nbsp;with&nbsp;entries&nbsp;we&nbsp;may&nbsp;<br />//not&nbsp;need&nbsp;we&nbsp;are&nbsp;a&nbsp;little&nbsp;specific<br /><br />//The&nbsp;third&nbsp;and&nbsp;optional&nbsp;parameter&nbsp;can&nbsp;be&nbsp;used&nbsp;to&nbsp;<br />//specify&nbsp;an&nbsp;alias&nbsp;for&nbsp;that&nbsp;table&nbsp;if&nbsp;the&nbsp;cache&nbsp;is&nbsp;<br />//being&nbsp;used&nbsp;over&nbsp;multiple&nbsp;tables&nbsp;with&nbsp;the&nbsp;same&nbsp;<br />//name.&nbsp;By&nbsp;default&nbsp;it&nbsp;uses&nbsp;the&nbsp;same&nbsp;name&nbsp;as&nbsp;the&nbsp;table&nbsp;<br />//for&nbsp;calls&nbsp;to&nbsp;LocalCache::find(),&nbsp;...<br /><br />//Internally&nbsp;the&nbsp;following&nbsp;is&nbsp;executed<br />//<br />//1)SHOW&nbsp;COLUMNS&nbsp;FROM&nbsp;`books`<br />//2)SELECT&nbsp;*&nbsp;FROM&nbsp;`books`&nbsp;WHERE&nbsp;`title`&nbsp;LIKE&nbsp;'PHP%'<br /></span><span style="color: #0000BB">$lcache</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">(</span><span style="color: #DD0000">'books'</span><span style="color: #007700">,&nbsp;[</span><span style="color: #DD0000">'title'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'PHP*'</span><span style="color: #007700">]);<br /><br /></span><span style="color: #FF8000">//Find&nbsp;the&nbsp;number&nbsp;of&nbsp;records&nbsp;loaded&nbsp;into&nbsp;cache<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">'There&nbsp;is&nbsp;currently&nbsp;%d&nbsp;book(s)&nbsp;matching&nbsp;\'PHP*\'&nbsp;loaded'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$lcache</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getNum</span><span style="color: #007700">(</span><span style="color: #DD0000">'books'</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">//We&nbsp;already&nbsp;know&nbsp;that&nbsp;the&nbsp;book&nbsp;we&nbsp;want&nbsp;to&nbsp;find&nbsp;have&nbsp;<br />//the&nbsp;id&nbsp;of&nbsp;'42'<br />//<br />//If&nbsp;this&nbsp;book&nbsp;is&nbsp;loaded&nbsp;into&nbsp;cache,&nbsp;then&nbsp;the&nbsp;records&nbsp;<br />//that&nbsp;matches&nbsp;the&nbsp;id&nbsp;of&nbsp;42&nbsp;is&nbsp;returned<br /></span><span style="color: #0000BB">$book&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$lcache</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">findSpecific</span><span style="color: #007700">(</span><span style="color: #DD0000">'books'</span><span style="color: #007700">,&nbsp;[</span><span style="color: #DD0000">'id'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">42</span><span style="color: #007700">]);<br /><br /></span><span style="color: #FF8000">//We&nbsp;can&nbsp;also&nbsp;get&nbsp;all&nbsp;the&nbsp;books&nbsp;loaded,&nbsp;but&nbsp;we&nbsp;only&nbsp;want&nbsp;the&nbsp;<br />//title&nbsp;of&nbsp;each<br /></span><span style="color: #0000BB">$books&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$lcache</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">(</span><span style="color: #DD0000">'books'</span><span style="color: #007700">,&nbsp;[</span><span style="color: #DD0000">'title'</span><span style="color: #007700">]);<br /><br /></span><span style="color: #FF8000">//List&nbsp;them<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'&lt;ul&gt;'</span><span style="color: #007700">;<br /><br />foreach(</span><span style="color: #0000BB">$books&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$book</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">'&lt;li&gt;%s&lt;/li&gt;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$book</span><span style="color: #007700">[</span><span style="color: #DD0000">'title'</span><span style="color: #007700">]);<br />}<br /><br />echo&nbsp;</span><span style="color: #DD0000">'&lt;/ul&gt;'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//We&nbsp;can&nbsp;also&nbsp;unload&nbsp;cache&nbsp;to&nbsp;free&nbsp;the&nbsp;memory&nbsp;or&nbsp;to&nbsp;<br />//force&nbsp;a&nbsp;recache<br /></span><span style="color: #0000BB">$lcache</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">unload</span><span style="color: #007700">(</span><span style="color: #DD0000">'books'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">'There&nbsp;is&nbsp;currently&nbsp;%d&nbsp;book&nbsp;entries&nbsp;loaded'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$lcache</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getNum</span><span style="color: #007700">(</span><span style="color: #DD0000">'books'</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code>
			</td>
		</tr>
	</table>
</fieldset>
	</div>
</div>





<h2><span>See also</span></h2>
<div class="box edge-title">
	<div class="inner">
		<ul>
			
			<li><a href="./classes.html">List of classes</a></li>
			<li><a href="./index.html">Table of contents</a></li>
		</ul>
	</div>
</div>

		<p>
			<em>Generated by Tuxxedo Engine 1.2.0 "Beloved" Release Candidate 2 (experimental). </em>
		</p>
	</body>
</html>